//
//  UILable+Extension.swift
//  weibo
//
//  Created by yellow on 15/10/20.
//  Copyright © 2015年 yellow. All rights reserved.
//

import UIKit

extension UILabel{

    /// 根据以下参数创建lable，大小自适应,并居中
    ///
    /// - returns: UILabel
    convenience init(title:String,color:UIColor,fontSize:CGFloat){
        self.init()
        text = title
        textColor = color
        font = UIFont.systemFontOfSize(fontSize)
        textAlignment = NSTextAlignment.Center
        sizeToFit()
    }
    
    
    /// 创建一个标签，文字靠右对齐，可换行，设置一行显示的最大宽度
    /// - parameter maxLayoutWidth: 设置标签的显示最大宽度
    ///
    /// - returns: UILabel
    convenience init(content:String,color:UIColor,fontSize:CGFloat,maxLayoutWidth:CGFloat){
        self.init()
        text = content
        textColor = color
        numberOfLines = 0
        font = UIFont.systemFontOfSize(fontSize)
        textAlignment = NSTextAlignment.Left
        preferredMaxLayoutWidth = maxLayoutWidth
    }
}
